package com.godz.frontData.index3;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.godz.mapper.index3WorkExpMapper;
import com.godz.pojo.index3WorkExp;
import org.springframework.web.bind.annotation.*;
import java.util.List;

//工作经历
@RestController
public class workExpData {
    final index3WorkExpMapper workExpMapper;

    public workExpData(index3WorkExpMapper workExpMapper){
        this.workExpMapper=workExpMapper;
    }

    @GetMapping("/index3/get/workExp")
    public List<index3WorkExp> getWork(){
        return workExpMapper.queryAllWork();
    }
    //查询单个
    @GetMapping("/index3/get/workExpOne/{intId}")
    public index3WorkExp getOneWork(@PathVariable("intId") Integer integer) {
        return workExpMapper.selectOne(
                new QueryWrapper<index3WorkExp>().eq("id", integer)
        );
    }
    //增加一条
    @PostMapping("/index3/post/addWork")
    public String addWork(@RequestBody index3WorkExp work) {
        workExpMapper.insert(work);
        return "insert OK";
    }
    //修改一条
    @PostMapping("/index/post/editWorkExp")
    public String editWorkExp(@RequestBody index3WorkExp workExp) {
        QueryWrapper<index3WorkExp> wrapper = new QueryWrapper<>();
        wrapper.eq("id", workExp.getId());

        index3WorkExp workExp1 = new index3WorkExp();
        workExp1.setWeCity(workExp.getWeCity());
        workExp1.setWeCon(workExp.getWeCon());
        workExp1.setWeName(workExp.getWeName());
        workExp1.setWeImg(workExp.getWeImg());
        workExp1.setWeSeva(workExp.getWeSeva());
        workExp1.setWeStart(workExp.getWeStart());
        workExp1.setWeEnd(workExp.getWeEnd());

        workExpMapper.update(workExp1, wrapper);
        return "Update OK";
    }
    //删除一条
    @GetMapping("/index3/get/deleteWork/{id}")
    public String deleteWork(@PathVariable("id") Integer integer) {
        workExpMapper.deleteById(integer);
        return "Delete Ok";
    }

}
